package com.aw.guiguzi.module.manager

import com.aw.baselib.base.AwBaseBindingActivity
import com.aw.baselib.base.AwBaseEvent
import com.aw.baselib.util.AwDataUtil
import com.aw.guiguzi.base.MyApp
import com.aw.guiguzi.databinding.ActivityManagerBinding
import com.aw.guiguzi.event.EventRefreshTransactionDataType
import com.aw.guiguzi.module.manager._files.FileListActivity
import com.aw.guiguzi.module.manager._login.LoginRecordListActivity
import com.aw.guiguzi.module.manager._user.UserListActivity
import com.aw.guiguzi.module.manager.msg.ManagerMsgListActivity
import com.aw.guiguzi.module.manager.transaction.ManagerTransactionActivity

class ManagerActivity : AwBaseBindingActivity<ActivityManagerBinding>() {

    override fun refreshByBus(type: AwBaseEvent?) {
        super.refreshByBus(type)
        if (type is EventRefreshTransactionDataType) {
            showView(binding.ivTransactionDataTag, !AwDataUtil.isEmpty(MyApp.transactionData))
        }
    }

    override fun getViewBinding(): ActivityManagerBinding {
        return ActivityManagerBinding.inflate(mActivity.layoutInflater)
    }

    override fun initData() {
        super.initData()
        setToolbar("管理中心", null)
        showView(binding.ivTransactionDataTag, !AwDataUtil.isEmpty(MyApp.transactionData))
    }

    override fun onResume() {
        super.onResume()
        showView(binding.ivTransactionDataTag, !AwDataUtil.isEmpty(MyApp.transactionData))
    }

    override fun initListener() {
        super.initListener()
        binding.tvToUserList.setOnClickListener {
            toClass(
                UserListActivity::class.java,
                false
            )
        }
        binding.tvToFileList.setOnClickListener {
            toClass(
                FileListActivity::class.java,
                false
            )
        }
        binding.tvToLoginList.setOnClickListener {
            toClass(
                LoginRecordListActivity::class.java,
                false
            )
        }
        binding.tvToMsgList.setOnClickListener {
            toClass(
                ManagerMsgListActivity::class.java,
                false
            )
        }
        binding.rlTransactionData.setOnClickListener {
            toClass(
                ManagerTransactionActivity::class.java,
                false
            )
        }
    }
}